﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Extensions.Options;
using Tsual.DataPipeline;
using Tsual.DataPipeline.AspCore;
using Tsual.DataPipeline.Redis;
using Tsual.DataPipeline.Http;
using System.Net.Http;
using System.Net;
using Newtonsoft.Json;
using Tsual.Wechat.Message.Impl;
using System.Threading.Tasks;
using Tsual.Wechat.Cache;
using RedLockNet.SERedis;
using StackExchange.Redis;

namespace Tsual.Wechat.Pipes
{
    public class PmouldWechatCore : AutoConfigurableMould<PmouldWechatCore>
    {
        public PmouldWechatCore(IOptions<ConfigurableMouldOption<PmouldWechatCore>> option, DataPipelineProvider provider) : base(option, provider)
        {
        }

        public DataPipeline<ExpirablePipeValue<string>, DpmmAccessToken, RedisExpirableStringPipe<DpmmAccessToken>, ReadonlyHttpPipe<ExpirablePipeValue<string>, DpmmAccessToken>> AccessToken { get; set; }

        public DataPipeline<ExpirablePipeValue<string>, DpmmAccessToken, RedisWriteonlyExpirableStringPipe<DpmmAccessToken>, ReadonlyHttpPipe<ExpirablePipeValue<string>, DpmmAccessToken>> AccessTokenForce { get; set; }

        public DataPipeline<string, DpmmKnownUser, RedisHashPipe<DpmmKnownUser>> KnownUsers { get; set; }

        public DataPipeline<WsrmUserAccessToken, DpmmUserAccessToken,
            MetaConvertedPipe<WsrmUserAccessToken, DpmmUserAccessToken, DpmmUserAccessTokenPageCache, RedisExpirableHashPipe<WsrmUserAccessToken, DpmmUserAccessTokenPageCache, DpmcUserPageCode>, DpmcUserPageCode>,
            RedisExpirableHashPipe<WsrmUserAccessToken, DpmmUserAccessToken, DpmcUserAccessToken>,
            CompositeReadPipe<
                WsrmUserAccessToken, DpmmUserAccessToken,
                DpmmUserRefreshTokenInner, DpmmUserRefreshToken,
                RedisExpirableHashPipe<DpmmUserRefreshTokenInner, DpmmUserRefreshToken, DpmcUserRefreshToken>,
                ReadonlyHttpPipe<WsrmUserAccessToken, DpmmUserRefreshTokenInner>,
                RedisExpirableDirectwriteHashPipe<WsrmUserAccessToken, DpmmUserRefreshToken, DpccRefreshTokenWrite>,
                DpmcUserAccessToken
                >,
            ReadonlyHttpPipe<WsrmUserAccessToken, DpmmUserAccessToken>
            >
            UserAccessToken
        { get; set; }
    }

    public class PmouldWechatTemplate : AutoConfigurableMould<PmouldWechatTemplate>
    {
        public PmouldWechatTemplate(IOptions<ConfigurableMouldOption<PmouldWechatTemplate>> option, DataPipelineProvider provider) : base(option, provider)
        {
        }

        public DataPipeline<WsrmTemplateId, DpmmQueryTemplateId, ReadonlyHttpPipe<WsrmTemplateId, DpmmQueryTemplateId>> QueryTemplateId { get; set; }

        public DataPipeline<WssmTemplateSend, DpmmSendTemplate, WriteonlyHttpPipe<WssmTemplateSend, DpmmSendTemplate>> SendTemplate { get; set; }
    }
}
